package com.zmj.sy.mom.srv.aps.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zmj.sy.mom.srv.aps.bean.entity.nest.NestSpacePart;
import com.zmj.sy.mom.srv.aps.bean.vo.nest.workspace.NestPartBindListResVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NestSpacePartMapper extends SyMapper<NestSpacePart>{

    @Delete("delete from tb_nest_space_part where id = #{id}")
    void deleteHardById(@Param("id") Integer id);

    @Select("SELECT spa.id AS id, pp.product_id AS productCode, pp.component_name AS parentName, pp.processing_no AS packageCode, pp.part_id AS plmId, pp.part_name AS partName, pp.replace_texture AS texture, " +
            "pp.replace_thickness AS thickness, spa.total_count AS planAmount, spa.finish_count AS finishAmount, (spa.total_count - spa.finish_count) AS restAmount, spa.`status` AS planStatus, " +
            "op.length AS length, op.width AS width, op.area AS area, spa.part_plan_id AS partPlanId, spa.space_id AS spaceId " +
            "FROM tb_nest_space_part spa LEFT JOIN tb_third_sinocam_pushplan pp ON spa.part_plan_id = pp.id LEFT JOIN tb_third_sinocam_pushdrawing pd ON pp.uni_mater_code = pd.uni_mater_code " +
            "LEFT JOIN tb_order_part op ON pp.part_id = op.plm_id " +
            " ${ew.customSqlSegment} ")
    List<NestPartBindListResVo> partBindList(@Param(Constants.WRAPPER) QueryWrapper<NestSpacePart> query);

}
